package com.woniu40.petai_manager.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu40.petai_manager.entity.Hospital;
import com.woniu40.petai_manager.entity.Role;
import com.woniu40.petai_manager.mapper.HospitalMapper;
import com.woniu40.petai_manager.vo.RoleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HospitalService {

    @Autowired
    HospitalMapper hospitalMapper;

    //查询医院列表
    public PageInfo<Hospital> findHospitalAll(String hospitalName, Integer pageNum, Integer pageSize){
        PageHelper.startPage(pageNum,pageSize);
        List<Hospital> hospitalList = hospitalMapper.selectAll(hospitalName);
        PageInfo<Hospital> pageInfo = new PageInfo<>(hospitalList);

        return pageInfo;
    }

    //查询一条医院信息
    public Hospital findHosById(Integer hospitalId){
        Hospital hospital = hospitalMapper.selectByPrimaryKey(hospitalId);
        return hospital;
    }
    //添加医院信息
    public int addHospital(Hospital hospital){
        hospitalMapper.insert(hospital);
        return 1;
    }

    //修改医院信息
    public int modifyHospital(Hospital hospital){
        hospitalMapper.updateByPrimaryKey(hospital);
        return 1;
    }

    //删除医院信息
    public int removeHospital(Integer hospitalId){
        hospitalMapper.deleteByPrimaryKey(hospitalId);
        return 1;
    }
}
